
# pip install PyExecJS
import execjs



# region

# result = execjs.eval("'Hello from JS'.length")
# print(result)  # 输出：14

# endregion


# region

# ctx = execjs.compile("""
#    function add(a, b) {
#        return a + b;
#    }
# """)
# print(ctx.call("add", 3, 5))  # 输出：8

# endregion

# region
js = open("1.js").read()
ctx = execjs.compile(js)
signature = ctx.call("add", 11, 11)
print(signature)

# endregion

# ctx = execjs.compile("""
#      const CryptoJS = require('crypto-js');
#      function encrypt(data, key) {
#          return CryptoJS.AES.encrypt(data, key).toString();
#      }
# """)
# encrypted = ctx.call("encrypt", "secret", "password")



